package com.itheima.reggie.common;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.List;

/**
 * @author : [wangtao]
 * @className : WebStatusResourceSupport
 * @description : [项目静态资源映射配置]
 * @createTime : [2022/10/6 11:09]
 * @updateTime : [2022/10/6 11:09]
 */
@Configuration
public class WebStatusResourceSupport extends WebMvcConfigurationSupport {
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
       registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/");
       registry.addResourceHandler("/front/**").addResourceLocations("classpath:/front/");
    }
/*
*springmvc 的消息转换器
* */

    @Override
    protected void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
        //1,创建springmvc消息转换器
        MappingJackson2HttpMessageConverter mjmc = new MappingJackson2HttpMessageConverter();
        //2,设置对象转换器,底层使用Jackson 将java 对象转换成josn
        mjmc.setObjectMapper(new JacksonObjectMapper());
          //3, 将上面的消息转换器对象追加到mvc框架的转换器集合中 放置在首位
        converters.add(0,mjmc);
//        super.extendMessageConverters(converters);

    }

}
